<?php
/**
 * default components.
 *
 * @package    Nika
 * @subpackage default
 * @author     Alexey Shapran (alexey.shapran@gmail.com)
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class defaultComponents extends sfComponents
{
	/**
	 * Get list of last registered users
	 *
	 * @author	Alexey Shapran <alexey.shapran@gmail.com>
	 */
	public function executeLastusers() 
	{
		$this->users = sfGuardUser::getLastRegistered();
	}

	/**
	 * Get list of last questions to priest
	 *
	 * @author	Alexey Shapran <alexey.shapran@gmail.com>
	 */
	public function executeLastquestions() 
	{
		$this->questions = Question::getLastQuestions();
	}

	/**
	 * Get list of last uploaded photo
	 *
	 * @author	Alexey Shapran <alexey.shapran@gmail.com>
	 */
	public function executeLastphoto() 
	{
		$this->photos = Doctrine_Query::create()
			    			->from('Media m')
			    			->where('m.media_type="photo"')
			    			->leftJoin('m.SfGuardUser u')
			    			->orderBy('created_at DESC')
			    			->limit(50)
			    			->execute();
	}

	/**
	 * Get list of last comments
	 *
	 * @author	Alexey Shapran <alexey.shapran@gmail.com>
	 */
	public function executeLastcomments() 
	{
		$this->comments = Doctrine_Query::create()
			    			->from('Comment c')
			    			->leftJoin('c.SfGuardUser u')
			    			->orderBy('created_at DESC')
			    			->limit(20)
			    			->execute();
	}
}
